import { ItemData } from "../../../resource/info/ItemData";
import { ECategory } from "../../../../../Message/Public/ECategory";
import { EJewel } from "../../../../../Message/Public/EJewel";
import { Cache } from "../../../cache/Cache";
type int = number;
//class JewelUtil
    
    export  class JewelUtil
    {
        

        public static isNormalJewel(arg1: ItemData): Boolean
        {
            if (arg1.category == ECategory._ECategoryJewel) 
            {
                var loc1=arg1.type;
                switch (loc1) 
                {
                    case EJewel._EJewelPower: case EJewel._EJewelAgile: case EJewel._EJewelHabitus: case EJewel._EJewelBrains: case EJewel._EJewelSpiritual:
                    {
                        return true;
                    }
                }
            }
            return false;
        }

        public static isPureJewel(arg1: ItemData): Boolean
        {
            if (arg1 && arg1.category == ECategory._ECategoryJewel && arg1.itemInfo.item.level == 2) 
            {
                return true;
            }
            return false;
        }

        public static isNeedSpecialCompose(arg1: ItemData): Boolean
        {
            if (arg1 && arg1.itemInfo.item.itemLevel >= 7 && arg1.itemInfo.item.itemLevel <= 8) 
            {
                if (JewelUtil.isNormalJewel(arg1)) 
                {
                    if (JewelUtil.isPureJewel(arg1) && arg1.itemInfo.item.itemLevel == 7) 
                    {
                        return true;
                    }
                }
                else if (!JewelUtil.isPureJewel(arg1)) 
                {
                    return true;
                }
            }
            return false;
        }

        public static isCanCompose(arg1: ItemData): Boolean
        {
            if (arg1.itemInfo.item.itemLevel < 7) 
            {
                return true;
            }
            return JewelUtil.isNeedSpecialCompose(arg1);
        }

        public static lv8IsCanCompose(arg1: int, arg2: int): Boolean
        {
            var loc1=null;
            var loc2=0;
            var loc3=Cache.instance.jewel.recipe;
            for(loc1 of loc3) 
            {
                if ((arg1 == loc1.material_jewel1 || arg1 == loc1.material_jewel1UnB) && (arg2 == loc1.material_jewel2 || arg2 == loc1.material_jewel2UnB)) 
                {
                    return true;
                }
                if (!((arg1 == loc1.material_jewel2 || arg1 == loc1.material_jewel2UnB) && (arg2 == loc1.material_jewel1 || arg2 == loc1.material_jewel1UnB))) 
                {
                    continue;
                }
                return true;
            }
            return false;
        }

        public static chooseJewelRecipe(arg1: ItemData=null): Array<any>
        {
            var loc3=null;
            var loc1=[];
            var loc2=Cache.instance.jewel.recipe;
            if (arg1 && arg1.itemInfo.item.itemLevel == 8) 
            {
                var loc4=0;
                var loc5=loc2;
                for(loc3 of loc5) 
                {
                    if (arg1.itemInfo.item.code == loc3.material_jewel1 || arg1.itemInfo.item.code == loc3.material_jewel1UnB) 
                    {
                        loc1.push(loc3.material_jewel2);
                        loc1.push(loc3.material_jewel2UnB);
                    }
                    if (!(arg1.itemInfo.item.code == loc3.material_jewel2 || arg1.itemInfo.item.code == loc3.material_jewel2UnB)) 
                    {
                        continue;
                    }
                    loc1.push(loc3.material_jewel1);
                    loc1.push(loc3.material_jewel1UnB);
                }
            }
            return loc1;
        }
    }
